function s2o(str) {
  // str =  /?username=zhangsan&pwd=123
  //  {username:"zhangsan",pwd:123};
  // 一、通过？号把str 切割
  let arr = str.split("?");
  // arr[1]  --- username=zhangsan&pwd=123
  let arr2 = arr[1].split("&");
  // arr2 ----    ['username=zhangsan','pwd=123'];
  return arr2.reduce((current, item) => {
    let arr3 = item.split("="); //  ["username","zhangsan"]
    // ["pwd","123"];
    current[arr3[0]] = arr3[1];
    return current;
  }, {});
}
let str = "/?username=zhangsan&pwd=123";
console.log(s2o(str));
// i/o : i:input  o:output  输入和输出；
// splice()
module.exports = s2o;
